Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#include "defs.h"
-#include "src/core/file.h"
-#include "src/core/xmlstreamwriter.h"
-#include <QDebug>
-#include <QXmlStreamReader>
-#include <QXmlStreamWriter>
+#include "mapfactor.h"
-static gpsbabel::File* oqfile;
-static QXmlStreamWriter* writer;
+#include <QByteArray> // for QByteArray
+#include <QIODevice> // for QIODevice, operator|, QIODevice::ReadOnly, QIODevice::Text, QIODevice::WriteOnly
+#include <QtGlobal> // for qPrintable
+#include <QStringLiteral> // for QStringLiteral
+#include <QXmlStreamAttributes> // for QXmlStreamAttributes
+#include <QXmlStreamReader> // for QXmlStreamReader, QXmlStreamReader::EndElement, QXmlStreamReader::StartElement
+#include <QXmlStreamWriter> // for QXmlStreamWriter
-static
-QVector<arglist_t> mapfactor_args = {
-};
+#include "defs.h" // for Waypoint, fatal, waypt_add, waypt_disp_all
+#include "src/core/file.h" // for File
+#include "src/core/xmlstreamwriter.h" // for XmlStreamWriter
-#define MYNAME "mapfactor"
-
-// This really should be class-local...
-static QXmlStreamReader reader;
-static QString mapfactor_read_fname;
-static const double milliarcseconds = 60.0 * 60.0 * 1000.0;
-geocache_container wpt_container(const QString&);
+#define MYNAME "mapfactor"
-static void MapfactorRead()
+void MapfactorFormat::MapfactorRead()
{
Waypoint* wpt = nullptr;
}
}
-static void
-mapfactor_rd_init(const QString& fname)
+void
+MapfactorFormat::rd_init(const QString& fname)
{
mapfactor_read_fname = fname;
}
-static void
-mapfactor_read()
+void
+MapfactorFormat::read()
{
gpsbabel::File file(mapfactor_read_fname);
file.open(QIODevice::ReadOnly);
}
}
-
-static void
-mapfactor_rd_deinit()
-{
-}
-
-static void
-mapfactor_wr_init(const QString& fname)
+void
+MapfactorFormat::wr_init(const QString& fname)
{
oqfile = new gpsbabel::File(fname);
oqfile->open(QIODevice::WriteOnly | QIODevice::Text);
writer->writeStartDocument();
}
-static void
-mapfactor_wr_deinit()
+void
+MapfactorFormat::wr_deinit()
{
writer->writeEndDocument();
delete writer;
oqfile = nullptr;
}
-static void
-mapfactor_waypt_pr(const Waypoint* waypointp)
+void
+MapfactorFormat::mapfactor_waypt_pr(const Waypoint* waypointp) const
{
writer->writeStartElement(QStringLiteral("item"));
writer->writeEndElement();
}
-static void
-mapfactor_write()
+void
+MapfactorFormat::write()
{
writer->writeStartElement(QStringLiteral("favourites"));
writer->writeAttribute(QStringLiteral("version"), QStringLiteral("1"));
// TODO: This could be moved to wr_init, but the pre GPX version put the two
// lines above this, so mimic that behaviour exactly.
writer->setAutoFormatting(true);
- waypt_disp_all(mapfactor_waypt_pr);
+ auto mapfactor_waypt_pr_lambda = [this](const Waypoint* waypointp)->void {
+ mapfactor_waypt_pr(waypointp);
+ };
+ waypt_disp_all(mapfactor_waypt_pr_lambda);
writer->writeEndElement();
}
-
-ff_vecs_t mapfactor_vecs = {
- ff_type_file,
- { (ff_cap)(ff_cap_read | ff_cap_write), ff_cap_none, ff_cap_none },
- mapfactor_rd_init,
- mapfactor_wr_init,
- mapfactor_rd_deinit,
- mapfactor_wr_deinit,
- mapfactor_read,
- mapfactor_write,
- nullptr,
- &mapfactor_args,
- CET_CHARSET_UTF8, 0 /* CET-REVIEW */
- , NULL_POS_OPS,
- nullptr
-};
--- /dev/null
+/*
+ Copyright (C) 2014 Robert Lipe
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ */
+#ifndef MAPFACTOR_H_INCLUDED_
+#define MAPFACTOR_H_INCLUDED_
+
+#include <QString> // for QString
+#include <QVector> // for QVector
+#include <QXmlStreamReader> // for QXmlStreamReader
+#include <QXmlStreamWriter> // for QXmlStreamWriter
+
+#include "defs.h" // for ff_cap, arglist_t, ff_cap_none, CET_CHARSET_UTF8, Waypoint, ff_cap_read, ff_cap_write, ff_type, ff_type_file
+#include "format.h" // for Format
+#include "src/core/file.h" // for File
+
+
+class MapfactorFormat : public Format
+{
+public:
+ QVector<arglist_t>* get_args() override
+ {
+ return &mapfactor_args;
+ }
+
+ ff_type get_type() const override
+ {
+ return ff_type_file;
+ }
+
+ QVector<ff_cap> get_cap() const override
+ {
+ /* waypoints, tracks, routes */
+ return { (ff_cap)(ff_cap_read | ff_cap_write), ff_cap_none, ff_cap_none };
+ }
+
+ QString get_encode() const override
+ {
+ return CET_CHARSET_UTF8;
+ }
+
+ int get_fixed_encode() const override
+ {
+ return 0;
+ }
+
+ void rd_init(const QString& fname) override;
+ void read() override;
+ void wr_init(const QString& fname) override;
+ void write() override;
+ void wr_deinit() override;
+
+private:
+ /* Constants */
+
+ static constexpr double milliarcseconds = 60.0 * 60.0 * 1000.0;
+
+ /* Member Functions */
+
+ void MapfactorRead();
+ void mapfactor_waypt_pr(const Waypoint* waypointp) const;
+
+ /* Data Members */
+
+ gpsbabel::File* oqfile{};
+ QXmlStreamWriter* writer{};
+
+ QVector<arglist_t> mapfactor_args = {
+ };
+
+ QXmlStreamReader reader;
+ QString mapfactor_read_fname;
+};
+#endif // MAPFACTOR_H_INCLUDED_
#include "kml.h"
#include "legacyformat.h"
#include "lowranceusr.h"
+#include "mapfactor.h"
#include "mynav.h"
#include "nmea.h"
#include "osm.h"
extern ff_vecs_t format_garmin_xt_vecs;
extern ff_vecs_t mapbar_track_vecs;
extern ff_vecs_t f90g_track_vecs;
-extern ff_vecs_t mapfactor_vecs;
#endif // MAXIMAL_ENABLED
class Vecs
GarminFitFormat format_fit_fmt;
LegacyFormat mapbar_track_fmt {mapbar_track_vecs};
LegacyFormat f90g_track_fmt {f90g_track_vecs};
- LegacyFormat mapfactor_fmt {mapfactor_vecs};
+ MapfactorFormat mapfactor_fmt;
EnergymproFormat energympro_fmt;
MyNavFormat mynav_fmt;
GeoJsonFormat geojson_fmt;